<?php
/**
 * @author @author Samrat Khan & Sadik Sarfaraz - Apr 11, 2013
 */
    require('top.inc.php');
?>
<?php
if(isset($_SESSION['user']) && $_SESSION['user']['utype'] == 1 || $_SESSION['user']['utype'] == 2) {
    // paginator
    if (isset($_GET["page"])) { $page  = $_GET["page"]; } else { $page=1; };
    $start_from = ($page-1) * 20;
    $rows = selectAllWhereForPanel("engineerinfo", "ASC", "engname", $start_from, 20, $db);
    $tPages = getCountForPanel('engineerinfo', 'eng_id', 20, $db);    
    
    echo "<div class='pagination'>";
        echo "<ul id='pagination-flickr'>";
            for ($i=1; $i<=$tPages; $i++) {
                echo "<li><a class='pagerbg active' href='viewengineers.php?page=".$i."'>".$i."</a></li>";
            };
        echo "</ul>";
    echo "</div>";
    
    //$rows = selectAll(ASC, "engname", "engineerinfo", $db);
    echo "<h5>Engineer Information</h5>";
    
    echo "<table class=\"row-fluid table table-striped table-bordered\">";
            echo "<tr>";
                echo "<th>";
                    echo $engineer_info['engname'];
                echo "</th>";
                echo "<th>";
                    echo $engineer_info['eng_id'];
                echo "</th>";
                echo "<th>";
                    echo $engineer_info['engcell'];
                echo "</th>";
                echo "<th>";
                    echo $wms_users['cus_id'];
                echo "</th>";
                echo "<th>";
                    echo $wms_users['inserteddate'];
                echo "</th>";
            echo "</tr>";
            
        foreach ($rows as $row) {
            echo "<tr>";
                echo "<td>";
                    echo $row['engname'];
                echo "</td>";
                echo "<td>";
                    echo $row['eng_id'];
                echo "</td>";
                echo "<td>";
                    echo $row['engcell'];
                echo "</td>";
                echo "<td>";
                    echo getCustomer($row['cus_id'], $db);
                echo "</td>";
                echo "<td>";
                    echo $row['inserteddate'];
                echo "</td>";
            echo "</tr>";
        }
    echo "<table>";
} else {
    header("Location: login.php");
}
?>

<?php
    include ('bottom.inc.php');
?>